<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Vue实例生命周期钩子(函数)</title>
    <script src="../../vue.js"></script>
</head>

<body>

    <div id="app">{{test}}</div>

    <script>
        const app = new Vue({
            el: '#app',
            data: {
                test: 'hello'
            },
            beforeCreate() {
                console.log('在vue实例创建之前执行');
            },
            created() {
                console.log('在创建时执行');
            },
            beforeMount() {
                console.log(this.$el); // 这时候要被接管的div还没有渲染好,还是: <div id="app">{{test}}</div>
                console.log('在实例安前时执行');
            },
            mounted() {
                console.log(this.$el); // 这时候被接管的div已经渲染好了: <div id="app">hello</div>
                console.log('安装时执行');
            },
            beforeDestroy() {
                console.log('在实例销毁前执行,在控制台使用vue对象.$destroy()进项销毁vue实例');
            },
            destroyed() {
                console.log('销毁时执行');
            },
            beforeUpdate() {
                console.log('在修改内容后重新渲染之前执行');
            },
            updated() {
                console.log('重新渲染时执行');
            },
        })
    </script>
</body>

</html>